package day04;

//for循环的演示
public class ForDemo {
    public static void main(String[] args) {
        for (int times = 0; times < 5; times++) {
            System.out.println("行动是成功的阶梯");
        }


        int sum = 0; //存和
        for (int i = 1; i <= 100; i++) {
            sum = sum + i; //累加
        }
        System.out.println("sum=" + sum);
        /*
          执行过程:
                 sum=0
           i=1   sum=1
           i=2   sum=1+2
           i=3   sum=1+2+3
           i=4   sum=1+2+3+4
           ...   sum=1+2+3+4+...
           i=99  sum=1+2+3+4+...+99
           i=100 sum=1+2+3+4+...+99+100
           i=101 false for循环结束
           输出sum=5050
         */
    }
}
